package com.leesche.zcsp.node.web.controller.web.computer;

import com.leesche.zcsp.node.utils.web.messge.WebResult;
import com.leesche.zcsp.node.utils.web.validation.Regex;
import com.leesche.zcsp.node.web.constants.Constants;
import com.leesche.zcsp.node.web.controller.template.UserTemplate;
import com.leesche.zcsp.node.web.model.PubCustomer;
import com.leesche.zcsp.node.web.model.SysUser;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * 
 * @Title: RegisterController.java
 * @Description: TODO(用户注册控制器)
 * @author Jerry Chen
 * @date 2016年10月5日 下午10:05:14
 * @version V1.0
 */
@Controller
@RequestMapping("/register")
public class RegisterController extends UserTemplate {

	private final static Logger LOGGER = Logger
			.getLogger(RegisterController.class.getName());

	private static final String REGISTER_VIEW = "web/userinfo/userinfo";
	private static final String PERFECT_VIEW = "web/userinfo/customerinfo";


	/*
	 * @Autowired private SysUserService sysUserService;
	 */

	@RequestMapping(value = "/gotoRegister", method = RequestMethod.GET)
	public String showUserInfoView() {
		return REGISTER_VIEW;
	}

	@RequestMapping(value = "/perfect", method = RequestMethod.GET)
	public String showCustomerInfoView() {
		return PERFECT_VIEW;
	}

	@ResponseBody
	@RequestMapping(value = "{code}/submitUserInfo", method = RequestMethod.POST)
	public Map<String, Object> addUserInfo(final SysUser sysUser,
			@PathVariable("code") String code, HttpSession session) {
		try {
			return createUserInfo(sysUser, code,Constants.MODULE_TYPE_WEB);
		} catch (Exception e) {
			// TODO: handle exception
			LOGGER.error(e, e);
			return WebResult.failure(e).toMap();
		}
	}

	@ResponseBody
	@RequestMapping(value = "/submitCustomerInfo", method = RequestMethod.POST)
	public Map<String, Object> addCustomerInfo(final PubCustomer customer) {

		return null;
	}

	@ResponseBody
	@RequestMapping(value = "/changeCustomerInfo", method = RequestMethod.POST)
	public Map<String, Object> changeCustomerInfo(final PubCustomer customer) {

		return null;
	}

}
